<template>
  <div>
    <div>
      <p class="title">推荐歌单</p>
      <van-row gutter="7">
        <van-col span="8" v-for="item in list" :key="item.id">
          <van-image fit="cover" :src="item.picUrl" />
          <p class="song_name">{{ item.name }}</p>
        </van-col>
      </van-row>
      <p class="title">最新音乐</p>
      <div>
        <van-list
          v-model="loading"
          :finished="finished"
          finished-text="没有更多了"
          @load="onLoad"
        >
          <van-cell v-for="item in newArr" :key="item.id">
            <template>
              <div class="song_item_wrap">
                <div class="song_left">
                  <p>{{ item.name }}</p>
                  <p>
                    <span>作者 - {{ item.song.artists[0].name }}</span> /
                    <span>专辑 {{ item.song.album.name }}</span>
                  </p>
                </div>
                <div class="song_right">
                  <i class="iconfont icon-bofang"></i>
                </div>
              </div>
            </template>
          </van-cell>
        </van-list>
      </div>
    </div>
  </div>
</template>

<script>
import { recommendAPI } from "@/api";
import { newSongAPI } from "@/api";
export default {
  data() {
    return {
      list: [],
      newArr: [],
      loading: false,
      finished: false,
    };
  },
  methods: {
    onLoad() {
      this.getNewSongFn();
    },
    async getNewSongFn() {
      const res2 = await newSongAPI({
        limit: 10,
      });
      this.newArr = res2.data.result;
      this.finished = true;
    },
  },
  async created() {
    const res = await recommendAPI();
    this.list = res.data.result;
  },
};
</script>

<style scoped>
.title {
  padding: 0.266667rem 0.24rem;
  margin: 0 0 0.24rem 0;
  background-color: #eee;
  color: #333;
  font-size: 15px;
}
.song_name {
  margin-bottom: 0.25rem;
  font-size: 0.346667rem;
  padding: 0rem 0.08rem;
  overflow: hidden;
  text-overflow: ellipsis;
  display: box;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/*歌单样式*/
.song_item_wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
/* 歌曲列表 */
.song_right {
  padding-right: 0.266667rem;
  line-height: 1.066667rem;
}

/* 歌曲_名字 */
.song_left {
  width: 8rem;
}
.song_left p:first-child {
  font-size: 0.453333rem;
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.song_left p:last-child {
  font-size: 0.32rem;
  color: #888;
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 播放图标 */
.song_right i {
  display: inline-block;
  transform: scale(1.3);
}
</style>